//
//  YJHomeTitleButton.swift
//  YJWeiBo
//
//  Created by Jim1024 on 2017/1/16.
//  Copyright © 2017年 Jim1024. All rights reserved.
//

import UIKit

class YJHomeTitleButton: UIButton {

    convenience init(title: String?, imageName: String) {
        self.init()
        setTitle(title, for: .normal)
        setTitleColor(UIColor.black, for: .normal)
        setImage(UIImage(named: imageName), for: .normal)
        sizeToFit()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 1.将label移动到最左边
        titleLabel?.frame.origin.x = 0
        // 2.图片移动到label后面
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
    }
}
